import type { RequestData } from '@ant-design/pro-table';
import { request } from 'umi';

/**
 * 工号自动完成
 *
 * @export
 * @param {String} keyword 查询参数
 * @returns
 */
export async function getOrderCodeAuthComplete(keyword: String) {
  return request<RequestData<String>>(`api/workorder/get-work-order-options?Keyword=${keyword}`);
}

/**
 * 目的地自动完成
 *
 * @export
 * @param {String} palletSpecification 提交参数
 * @returns
 */
export async function getDestinationAuthComplete(palletSpecification: String) {
  return request<RequestData<String>>(`api/unitloads/get-outbound-targets`, {
    method: 'POST',
    data: {palletSpecification: palletSpecification}
  });
}

/**
 * 校验托盘号
 *
 * @export
 * @param {String} palletCode 查询参数
 * @returns
 */
 export async function checkPalletCode(PalletCode: String) {
  return request<RequestData<String>>(`api/unitloads/check-pallet?PalletCode=${PalletCode}`, {
    method: "POST",
  });
}  

/**
 * 校验物料码
 * @param qrCode 
 * @returns 
 */
export async function checkQrcode(qrCode: String) {
    return request<RequestData<String>>(`api/unitloads/check-qrcode?qrCode=${qrCode}`, {
        method: "POST",
    });
}

/**
 * 根据物料码获取订单信息
 * @param qrCode 
 * @param jobNo 
 * @returns 
 */
export async function getWorkordersToQrcode(qrCode: String, jobNo: String) {
  return request<RequestData<String>>(`api/unitloads/get-workorders-to-qrcode?qrCode=${qrCode}`, {
    method: "POST",
    data: {jobNo: jobNo}
  });
}

/**
 * 提交托盘类型和目的点到后台
 * @param palletType 
 * @param destination 
 * @returns 
 */
export async function postPalletAndDestination(palletType: String, destination: String) {
  return request<RequestData<String>>(`api/unitloads/postPalletAndDestination`, {
    method: "POST",
    data: {palletType: palletType, destination: destination}
  });
}

/**
 * 组盘
 * @param palletType 
 * @param destination 
 * @returns 
 */
 export async function postPalletize(jobNo: String, palletCode: String, QRCodes: never[]) {
  return request<RequestData<String>>(`api/unitloads/palletize`, {
    method: "POST",
    data: {jobNo: jobNo, palletCode: palletCode, QRCodes: QRCodes}
  });
}